XFLAGS = -Wall -O3 -fpermissive

ifeq ($(OS), Win)
    EXT = .exe
    EXT_SO = .dll
    PREF_SO =
    LIBS =
    XFLAGS += -D_WIN32
endif

ifeq ($(OS), Nix)
    EXT =
    EXT_SO = .so
    PREF_SO = lib
    LIBS = -ldl -lpthread -lrt
    XFLAGS += -D_OS_NIX
endif

all: service_registry class_factory test1 test2 test3

service_registry:
	g++ $(XFLAGS) -shared ./components/service_registry/*.cpp -o ./bin/$(PREF_SO)service_registry$(EXT_SO) $(LIBS)

class_factory:
	g++ $(XFLAGS) -shared ./components/class_factory/*.cpp -o ./bin/$(PREF_SO)class_factory$(EXT_SO) $(LIBS)

test1: test1_1 test1_2
	g++ $(XFLAGS) ./tests/test1/*.cpp -o ./bin/test1$(EXT) $(LIBS)

test1_1:
	g++ $(XFLAGS) -shared  ./tests/test1/component1/*.cpp -o ./bin/$(PREF_SO)test_component1$(EXT_SO) $(LIBS)

test1_2:
	g++ $(XFLAGS) -shared ./tests/test1/component2/*.cpp -o ./bin/$(PREF_SO)test_component2$(EXT_SO) $(LIBS)

test2:
	g++ $(XFLAGS) ./tests/test2/*.cpp -o ./bin/test2$(EXT) $(LIBS)

test3:
	g++ $(XFLAGS) ./tests/test3/*.cpp -o ./bin/test3$(EXT) $(LIBS)
